home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
DATABASE.DIR
/
00099_Script_CastNumber scripts
< prev
next >
Wrap
Text File
|
1996-03-28
|
4KB
|
132 lines
-- --------------------------------------------------------------
-- Handler setUpCastNumbersFields puts the appropriate data
-- into the given fields
on setUpCastNumbersFields
put empty into field "CastNumbers 1"
set numTopics = the number of lines in field "browserTopics"
repeat with i = 1 to numTopics
set topic = line i of field "browserTopics"
put topic
put topic & ":" after field "CastNumbers 1"
-- gather text casts
gatherCasts(topic, "TEXT")
put ":" after field "CastNumbers 1"
-- gather picture casts
gatherCasts(topic, "PICTURE")
put ":" after field "CastNumbers 1"
-- gather caption casts
gatherCasts(topic, "CAPTION")
put RETURN after field "CastNumbers 1"
end repeat
end
-- --------------------------------------------------------------
-- Handler gatherCasts adds the casts of the given type for the
-- to the field "CastNumbers 1".
on gatherCasts topic, type
set continue = TRUE
set index = 1
repeat while continue
put type
set theCast = the number of cast (topic && type & index)
if (theCast = -1) then
-- delete the last space
delete the last char of field "CastNumbers 1"
-- drop out of the text repeat loop
set continue = false
else
put theCast & " " after field "CastNumbers 1"
set index = index + 1
end if
end repeat -- gathering casts
end
-- --------------------------------------------------------------
-- Handler initTextCastNumbersList initializes the global variable
-- topicCastData to the fields "CastNumbers 1" and
-- "CastNumbers 2" which contains a list of text cast names
-- and their corresponding cast numbers.
on initTextCastNumbersList
global topicCastData
set topicCastData = field "CastNumbers 1" -- & field "CastNumbers 2"
end
-- --------------------------------------------------------------
-- Handler getTextCastNumber returns the cast number of the given
-- page of text of the given topic by performing a binary search
-- on the global variable topicCastData.
on getTextCastNumber whichTopic, whichPage
global topicCastData
set the itemDelimiter = ":"
set theLine = binSearchFirstItemInLine (topicCastData, whichTopic, ":")
if (theLine = 0) then
set the itemDelimiter = ","
return -1
end if
set textCastNum = integer(word whichPage of item 2 of line theLine of topicCastData)
set the itemDelimiter = ","
return textCastNum
end
-- --------------------------------------------------------------
-- Handler getPictureCastNumber returns the cast number of the given
-- picture of the given topic by performing a binary search
-- on the global variable topicCastData.
on getPictureCastNumber whichTopic, whichPicture
global topicCastData
set the itemDelimiter = ":"
set theLine = binSearchFirstItemInLine (topicCastData, whichTopic, ":")
if (theLine = 0) then
set the itemDelimiter = ","
return -1
end if
set pictureCastNum = integer(word whichPicture of item 3 of line theLine of topicCastData)
set the itemDelimiter = ","
return pictureCastNum
end
-- --------------------------------------------------------------
-- Handler getCaptionCastNumber returns the cast number of the given
-- caption of the given topic by performing a binary search
-- on the global variable topicCastData.
on getCaptionCastNumber whichTopic, whichCaption
global topicCastData
set the itemDelimiter = ":"
set theLine = binSearchFirstItemInLine (topicCastData, whichTopic, ":")
if (theLine = 0) then
set the itemDelimiter = ","
return -1
end if
set captionCastNum = integer(word whichCaption of item 4 of line theLine of topicCastData)
set the itemDelimiter = ","
return captionCastNum
end